package com.hxy.tlias.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
@WebFilter("/*")  //设置拦截路径
public class DemoFilter implements Filter {
    //初始化
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("DemoFilter...init...");
    }
    //销毁，web服务器正常关闭会触发
    @Override
    public void destroy() {
        log.info("DemoFilter...destory...");
    }
    //过滤请求
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("DemoFilter...doFilter...");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
    }
}
